function rest = index2(k)

rest=[ones(k-1,1),eye(k-1)];
for ii=k-1:-1:1
    tmp=[zeros(ii-1,k-ii),ones(ii-1,1),eye(ii-1)];
    rest=[rest;tmp];
end